-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
All: Fix format of geolocation data #2673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4f9b90f
to
78f78f1
Compare
Hmm, I'm not sure what specific bug is fixed by this change? The geolocation should indeed be a string internally because float is imprecise, then we use the function Note.filter() to normalise the data when it needs to be compared. My concern is whether changing how the geolocation is represented could incorrectly trigger synchronisation of existing notes. |
Consider that we have a note, we
The bug is that after serialize/unserialize, the geolocation is no longer represented internally as a string. So notes on either end of a sync have different representations. BeforeFor example, without the proposed fix, it looks like this : Note fields before serialization:
Note fields after unserialization:
The problem is the fields are converted from strings to floats AfterWith the fix proposed in this PR, the fields are restored as strings after unserialization. Note fields after (fixed) unserialization:
|
78f78f1
to
aba8175
Compare
aba8175
to
8e471f8
Compare
Hmm, I don't know. When I've implemented this, I remember spending quite a bit of time to make sure geolocation is stable (at first it wasn't) and doesn't get resynced when a note is unserialised/serialised. My concern is whether sync is going to be impacted by this change in unseralisation. As you said, before it was unserialised as a float "73.5171", now as a string "73.51710000". Maybe that's fine, or maybe not, but I'm having trouble evaluating the impact of this change. |
Temporarily closing until I get time to come back to investigate and address comments. |
My understanding is that notes are flagged for sync when they are saved, so a change in unserialise format has no effect. This is the case for all uses of unserialise: in sync, export/import RAW, external editting and encryption. Perhaps the only way to confirm this is to do a manual test:
Would that be sufficient to prove the change is benign? Otherwise perhaps we just leave it as is. |
I had a look at it again into more details, and can't see any issue with it, so let's merge. Thanks @mic704b! |
Geolocation data changes format through serialization between number and string. It means that the clients on either end of a sync hold the same data but in different formats. It is expected that it would be identical on both clients.
The database specifies the format of geo data as NUMBER. However the app seems to use it as formatted string.
One solution is to modify the database so the format is specified as STRING. However this would require a database migration upon upgrade, I'm not sure how simple that would be for a base data type.
Alternatively, though not ideal, here we propose to make an exception for geo data in the BaseItem serialization methods so that the database specification is ignored, and the format is maintained as string throughout serialization / unserialization.